home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 138 / 138.xpi / chrome / stumbleupon.jar / content / discoveryDialog.xul < prev    next >
Extensible Markup Language  |  2009-10-04  |  2KB  |  85 lines

  1. <?xml version="1.0"?>
  2.  
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  4.  
  5. <window id="stumble_discovery_dialog" title="Discovery - StumbleUpon"
  6.   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  7.   onload="init();"
  8.   style="background-color:white;">
  9.  
  10. <script type="application/x-javascript">
  11. <![CDATA[
  12.  
  13. var detail;
  14. var browser;
  15.  
  16. function init()
  17. {
  18.     detail = window.arguments[0];
  19.     // Old, Straightforward technique is commented out for now.
  20.     // We use XMLHttpRequest instead to work around a NoScript problem.  NoScript by default will
  21.     // block cross-domain POST requests, even if they are from a Chrome URL.  We are hoping Giorgio
  22.     // will fix this, but until then we need to use the XmlHttpRequest workaround.
  23.     browser = document.getElementById("browser");
  24.     var url = opener.su_base_url + detail.uri_suffix;
  25.     
  26.     browser.webNavigation.loadURI(
  27.                 url,
  28.                 Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE,
  29.                 opener.su_get_nsiuri(opener.getBrowser().contentDocument.referrer),
  30.                 opener.su_get_mime_input_stream(detail.postdata, "application/x-www-form-urlencoded"),
  31.                 null); // headers
  32.     browser.addEventListener("click", handle_content_click, false);
  33.  
  34. }
  35.  
  36. function handle_content_click(event)
  37. {
  38.     if (event.originalTarget.hasAttribute("ondblclick"))
  39.         ondblclick = event.originalTarget.getAttribute("ondblclick");
  40.     
  41.     var current_page = opener.su_get_browser_url(event.target.ownerDocument, true);
  42.     
  43.     if(ondblclick == "whitelist_stumbleupon_with_noscript")
  44.     {
  45.         var tld = opener.su_get_tld(current_page);
  46.         if (tld == opener.su_servername)
  47.         {
  48.             opener.su_update_noscript_whitelists();
  49.             var ps = opener.su_get_service(
  50.                         "@mozilla.org/embedcomp/prompt-service;1",
  51.                         "nsIPromptService");
  52.             
  53.             ps.alert(window, "StumbleUpon", "NoScript configuration updated.  Please try the operation again.");
  54.             window.close();
  55.         }
  56.     }
  57.  
  58.     return true;
  59. }
  60.  
  61. function handle_submit_command()
  62. {
  63.     try {
  64.         var el = browser.contentDocument.getElementById("tagtext");
  65.         if (el)
  66.             detail.tagtext = decodeURIComponent(el.getAttribute("value"));
  67.     } catch (e) {}
  68.     detail.submitted = true;
  69.     window.close();
  70. }
  71.  
  72. function handle_cancel_command()
  73. {
  74.     window.close();
  75. }
  76.  
  77. document.addEventListener("RATING_CANCELLED", handle_cancel_command, false, true);
  78. document.addEventListener("RATING_SUBMITTED", handle_submit_command, false, true);
  79.  
  80. ]]>
  81. </script>
  82. <browser id="browser" 
  83. flex="1"/>
  84. </window>
  85.